/*  This file is part of -_-.

    -_- is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    -_- is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with -_-.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2012-2013 Oliver Katz */

#include <iostream>
#include "../../common/debug.h"
#include "../../arch/arch.h"
#include "../../arch/modules/mod_argbuf.h"
#include "../../arch/modules/mod_bus.h"
#include "../../arch/modules/mod_codeserver.h"
#include "../../arch/modules/mod_log.h"
#include "../../arch/modules/mod_share_client.h"
#include "../../arch/modules/mod_share_server.h"
#include "../../arch/modules/mod_ipc_client.h"
#include "../../arch/modules/mod_ipc_server.h"
#include "../../arch/modules/mod_visual_script.h"

#include <gtest/gtest.h>

using namespace sleepyface;
using namespace sleepyface::arch;
using namespace sleepyface::visual;
using namespace sleepyface::visual::script;

Architecture *a;

TEST(visualClient, client)
{
    ModuleSignal s = ModuleSignal(modules::IPCClient::signalConnect);
    s.append(ModuleValue(ModuleValue::_string, "visual-server"));
    s.append(ModuleValue(ModuleValue::_string, "127.0.0.1"));
    s.append(ModuleValue(ModuleValue::_int, 8952));
    ASSERT_FALSE(a->module("ipc-client")->signal(s, *a));

    a->module("visual-script")->set("test", "x", ModuleValue(ModuleValue::_int, 100), *a);
    a->module("visual-script")->set("test", "y", ModuleValue(ModuleValue::_int, 100), *a);
    a->module("visual-script")->set("test", "w", ModuleValue(ModuleValue::_int, 200), *a);
    a->module("visual-script")->set("test", "h", ModuleValue(ModuleValue::_int, 200), *a);

    s = ModuleSignal(modules::VisualScript::signalRequestAppSpace);
    s.append(ModuleValue(ModuleValue::_string, "test"));
    ASSERT_FALSE(a->module("visual-script")->signal(s, *a));
}

int main(int argc, char *argv[])
{
    ::testing::InitGoogleTest(&argc, argv);

    Z_DEBUG_INIT(argv[0]);

    a = new Architecture("test-visual-client");

    a->loadRequiredInternals();
    a->loadOptionalInternals(argc, argv);

    return RUN_ALL_TESTS();
}
